package com.wanggsx.plugindemo

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.Toast
import com.wamggsx.pluginapp.R
import com.wanggsx.pluginlib.PluginActivity

class MainActivity : PluginActivity() {
    lateinit var mRootView : View

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("pluginmain","onCreate")
        setContentView(R.layout.activity_main)
    }

    override fun onStart() {
        super.onStart()
        findViewById<Button>(R.id.btnShow).setOnClickListener(
            View.OnClickListener{
                run {
                    if (mProxyActivity != null) {
                        Toast.makeText(mProxyActivity, "hello!", Toast.LENGTH_SHORT).show()
                    } else {
                        Toast.makeText(MainActivity@this, "hello!", Toast.LENGTH_SHORT).show()
                    }
                }
            }
        )
        Log.d("pluginmain","onStart")
    }

    override fun onResume() {
        super.onResume()
        Log.d("pluginmain","onResume")
    }

    override fun onPause() {
        super.onPause()
        Log.d("pluginmain","onPause")
    }

    override fun onStop() {
        super.onStop()
        Log.d("pluginmain","onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d("pluginmain","onDestroy")
    }

}
